//go:build wireinject
// +build wireinject

package repositoryWire

import (
	adminModel "gin_http/internal/model/admin"
	adminRepository "gin_http/internal/repository/admin"
	commonRepository "gin_http/utils/common/repository"
	"gin_http/utils/db"

	"github.com/google/wire"
	"gorm.io/gorm"
)

// ProvideBaseAdminUserRepository 管理员用户基础仓储类
func ProvideBaseAdminUserRepository(db *gorm.DB) *commonRepository.BaseRepository[adminModel.User] {
	return commonRepository.NewBaseRepository[adminModel.User](db)
}

// ProvideBaseAdminRoleRepository 管理员角色基础仓储类
func ProvideBaseAdminRoleRepository(db *gorm.DB) *commonRepository.BaseRepository[adminModel.Role] {
	return commonRepository.NewBaseRepository[adminModel.Role](db)
}

var UserRepoSet = wire.NewSet(
	db.GetDB,                          // *gorm.DB provider
	ProvideBaseAdminUserRepository,    // BaseRepository[User] provider
	adminRepository.NewUserRepository, // 依赖 BaseRepository[User]
)

var RoleRepoSet = wire.NewSet(
	db.GetDB,                          // *gorm.DB provider
	ProvideBaseAdminRoleRepository,    // BaseRepository[Role] provider
	adminRepository.NewRoleRepository, // 依赖 BaseRepository[Role]
)

func InitAdminUserRepository() (*adminRepository.UserRepository, error) {
	wire.Build(UserRepoSet)
	return &adminRepository.UserRepository{}, nil
}

func InitAdminRoleRepository() (*adminRepository.RoleRepository, error) {
	wire.Build(RoleRepoSet)
	return &adminRepository.RoleRepository{}, nil
}
